package com.abo.yaas.view;

import com.vaadin.ui.Component;
import com.vaadin.ui.Panel;

@SuppressWarnings("serial")
public class SimpleViewContainer extends AbstractView<Panel> implements
        ViewContainer {

    public SimpleViewContainer() {
        super(new Panel());
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void activate(View view) {
        if (!(view instanceof Component)) {
            throw new IllegalArgumentException("View must be a component");
        }
        getContent().removeAllComponents();
        getContent().addComponent((Component) view);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void activated(Object... params) {
        // Do nothing
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void deactivate(View view) {
        getContent().removeAllComponents();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void deactivated(Object... params) {
        // Do nothing
    }

}
